<?php
/* 
 * 项目表
 */

class Project extends CActiveRecord
{
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    }

    public function tableName()
    {
        return 'project';
    }
    const PROJECT_NOMAIL = -1;//项目初始状态，
    const PROJECT_RUNNING = 1;  //项目状态：运行中
    const PROJECT_FINISH = 2;  //项目状态：完结，完结的项目前台看不到
    const PROJECT_DELETE = 0;  //项目状态：删除

    /*
     * 获取项目所有状态
     */
    public static function projectStatus()
    {
            return array(
					self::PROJECT_NOMAIL => '未开始',
                    self::PROJECT_RUNNING =>  '运行中',
                    self::PROJECT_FINISH => '完结',
                    self::PROJECT_DELETE => '删除'
            );
    }
    /**
     * 得到网点的项目
     */
    public function getByNetwork($network_id)
    {
        $data = $this->findAll('network_id='.$network_id);
        if ($data) 
        {
            $result = array();
            foreach ($data as $val) {
                $v = $val->attributes;
                $result[$v['project_id']] = $v;
            }
            return $result;
        }
        return $data;
    }
}